package error;

import org.apache.commons.lang3.StringUtils;

import android.util.Log;
import code.CategoryComponet;
import code.CategoryComponetImpl;
import dominain.AbstractExeDTO;

public class JException extends RuntimeException {

	/** The msg. */
	private String msg = "";

	/** The code. */
	private String code = "";

	/** The full error msg. */
	private String fullErrorMsg = "";

	private AbstractExeDTO exe = null;

	/** The love code componet. */
	private CategoryComponet loveCodeComponet = null;

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * Instantiates a new love exception.
	 * 
	 * @param code
	 *            the code
	 * @param msg
	 *            the msg
	 */
	public JException(String code, String msg) {
		this.loveCodeComponet = new CategoryComponetImpl(exe);
		this.msg = msg;
		this.code = code;
		fullErrorMsg += loveCodeComponet.getContentFromErrorTable(code);
		if (!StringUtils.isBlank(msg)) {
			fullErrorMsg += ":";
			fullErrorMsg += msg;
		}

		Log.e("JException ERROR", code + fullErrorMsg);
	}

	/**
	 * Instantiates a new love exception.
	 * 
	 * @param code
	 *            the code
	 */
	public JException(String code) {
		this(code, "");
	}

	/**
	 * Gets the full error msg.
	 * 
	 * @return the full error msg
	 */
	public String getFullErrorMsg() {
		return fullErrorMsg;
	}

	/**
	 * Gets the msg.
	 * 
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * Sets the msg.
	 * 
	 * @param msg
	 *            the new msg
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * Gets the code.
	 * 
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * Sets the code.
	 * 
	 * @param code
	 *            the new code
	 */
	public void setCode(String code) {
		this.code = code;
	}

	public CategoryComponet getLoveCodeComponet() {
		return loveCodeComponet;
	}

	public void setLoveCodeComponet(CategoryComponet loveCodeComponet) {
		this.loveCodeComponet = loveCodeComponet;
	}

	/**
	 * Sets the full error msg.
	 * 
	 * @param fullErrorMsg
	 *            the new full error msg
	 */
	public void setFullErrorMsg(String fullErrorMsg) {
		this.fullErrorMsg = fullErrorMsg;
	}
}
